package com.util;

import java.io.Serializable;

/**
 * 页面助手
 * @author Administrator
 *
 */
public class PageAssistant implements Serializable {

	/** 总记录数 */
	private int count;
	/** 总页数 */
	private int totalPage;
	/** 页面多少(显示数据的条数) */
	private int pageSize = 5;
	/** 当前页码 */
	private int currPage = 1;
	/** 起始数据编号 */
	private int start = 1;
	/** 结束数据编号 */
	private int end = 5;
	
	public int getCount() {
		return count;
	}
	public void setCount(int count) {
		this.count = count;
		setTotalPage();
	}
	
	public int getTotalPage() {
		return totalPage;
	}
	private void setTotalPage() {
		
		totalPage = count / pageSize;
		
		//判断, 是否整除
		if(count % pageSize != 0){
			totalPage++;
		}
	}
	
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
		setTotalPage();
		setStart();
		setEnd();
	}
	
	public int getCurrPage() {
		return currPage;
	}
	public void setCurrPage(int currPage) {
		this.currPage = currPage;
		setStart();
		setEnd();
	}
	
	public int getStart() {
		return start;
	}
	private void setStart() {
		start = (currPage-1) * pageSize + 1;
	}
	
	public int getEnd() {
		return end;
	}
	private void setEnd() {
		end = currPage * pageSize;
	}
	
}







